package com.monitor.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.monitor.entity.ErpSaleRepairRepair;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 销售维修-轮胎维修表 Mapper 接口
 * </p>
 *
 * @author LX
 * @since 2018-09-12
 */
public interface ErpSaleRepairRepairMapper extends BaseMapper<ErpSaleRepairRepair> {
	@Select("SELECT COUNT(1) from erp_sale_repair_repair srr, erp_sale_repair_order sro where srr.order_id=sro.id and srr.materiel_source like #{sourse} and srr.materiel_out_to not like #{outTo} and sro.customer_name=#{custName} and sro.sale_repair_date>=#{startTime} and sro.sale_repair_date<#{endTime}")
	public Integer selectBySourseAndOutTo(@Param("sourse")String sourse,@Param("outTo")String outTo,@Param("custName")String custName,@Param("startTime")String startTime,@Param("endTime")String endTime);
	
	@Select("SELECT SUM(s.materiel_number), s.materiel_name 	FROM erp_sale_repair_repair s WHERE 	s.order_id in (${sroId})	GROUP BY s.materiel_name ")
	public List<Map<String,Object>> selectBySroId(@Param("sroId")String sroId);
	
	@Select("SELECT * from erp_sale_repair_repair s where s.order_id in (${orderIds}) and s.materiel_out_to like '%客户%' ")
	public List<ErpSaleRepairRepair> selectByOrderIds(@Param("orderIds")String orderIds);
}
